<HTML>
<BODY BGCOLOR="white">
<PRE>
<FONT color="green">001</FONT>    package org.hackystat.projectbrowser.page.telemetry;<a name="line.1"></a>
<FONT color="green">002</FONT>    <a name="line.2"></a>
<FONT color="green">003</FONT>    import static org.junit.Assert.assertEquals;<a name="line.3"></a>
<FONT color="green">004</FONT>    import static org.junit.Assert.assertFalse;<a name="line.4"></a>
<FONT color="green">005</FONT>    import static org.junit.Assert.assertTrue;<a name="line.5"></a>
<FONT color="green">006</FONT>    import static org.junit.Assert.fail;<a name="line.6"></a>
<FONT color="green">007</FONT>    import java.util.ArrayList;<a name="line.7"></a>
<FONT color="green">008</FONT>    import java.util.List;<a name="line.8"></a>
<FONT color="green">009</FONT>    import java.util.Properties;<a name="line.9"></a>
<FONT color="green">010</FONT>    import javax.xml.datatype.XMLGregorianCalendar;<a name="line.10"></a>
<FONT color="green">011</FONT>    import org.apache.wicket.Component;<a name="line.11"></a>
<FONT color="green">012</FONT>    import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;<a name="line.12"></a>
<FONT color="green">013</FONT>    import org.apache.wicket.markup.html.form.DropDownChoice;<a name="line.13"></a>
<FONT color="green">014</FONT>    import org.apache.wicket.markup.html.form.ListMultipleChoice;<a name="line.14"></a>
<FONT color="green">015</FONT>    import org.apache.wicket.markup.html.list.ListView;<a name="line.15"></a>
<FONT color="green">016</FONT>    import org.apache.wicket.util.tester.FormTester;<a name="line.16"></a>
<FONT color="green">017</FONT>    import org.apache.wicket.util.tester.WicketTester;<a name="line.17"></a>
<FONT color="green">018</FONT>    import org.hackystat.projectbrowser.ProjectBrowserApplication;<a name="line.18"></a>
<FONT color="green">019</FONT>    import org.hackystat.projectbrowser.ProjectBrowserProperties;<a name="line.19"></a>
<FONT color="green">020</FONT>    import org.hackystat.projectbrowser.authentication.SigninPage;<a name="line.20"></a>
<FONT color="green">021</FONT>    import org.hackystat.projectbrowser.page.loadingprocesspanel.LoadingProcessPanel;<a name="line.21"></a>
<FONT color="green">022</FONT>    import org.hackystat.projectbrowser.page.telemetry.datapanel.TelemetryDataPanel;<a name="line.22"></a>
<FONT color="green">023</FONT>    import org.hackystat.projectbrowser.page.telemetry.inputpanel.TelemetryDescriptionPanel;<a name="line.23"></a>
<FONT color="green">024</FONT>    import org.hackystat.projectbrowser.page.telemetry.inputpanel.TelemetryInputPanel;<a name="line.24"></a>
<FONT color="green">025</FONT>    import org.hackystat.projectbrowser.test.ProjectBrowserTestHelper;<a name="line.25"></a>
<FONT color="green">026</FONT>    import org.hackystat.sensorbase.resource.projects.jaxb.Project;<a name="line.26"></a>
<FONT color="green">027</FONT>    import org.hackystat.telemetry.service.resource.chart.jaxb.TelemetryChartDefinition;<a name="line.27"></a>
<FONT color="green">028</FONT>    import org.hackystat.utilities.tstamp.Tstamp;<a name="line.28"></a>
<FONT color="green">029</FONT>    import org.junit.After;<a name="line.29"></a>
<FONT color="green">030</FONT>    import org.junit.Before;<a name="line.30"></a>
<FONT color="green">031</FONT>    import org.junit.Test;<a name="line.31"></a>
<FONT color="green">032</FONT>    <a name="line.32"></a>
<FONT color="green">033</FONT>    /**<a name="line.33"></a>
<FONT color="green">034</FONT>     * Tests for Telemetry page.<a name="line.34"></a>
<FONT color="green">035</FONT>     * @author Shaoxuan Zhang<a name="line.35"></a>
<FONT color="green">036</FONT>     */<a name="line.36"></a>
<FONT color="green">037</FONT>    public class TestTelemetryPage extends ProjectBrowserTestHelper {<a name="line.37"></a>
<FONT color="green">038</FONT>      /** the test user. */<a name="line.38"></a>
<FONT color="green">039</FONT>      private String testUser = "TestTelemetryUser";<a name="line.39"></a>
<FONT color="green">040</FONT>      /** email of the test user. */<a name="line.40"></a>
<FONT color="green">041</FONT>      private String testUserEmail = "TestTelemetryUser@hackystat.org";<a name="line.41"></a>
<FONT color="green">042</FONT>      /** the test project. */<a name="line.42"></a>
<FONT color="green">043</FONT>      private String testProject = "TestTelemetryProject";<a name="line.43"></a>
<FONT color="green">044</FONT>      /** String of telemetry, for properties. */<a name="line.44"></a>
<FONT color="green">045</FONT>      private String telemetry = ".telemetry";<a name="line.45"></a>
<FONT color="green">046</FONT>      /** String of true. */<a name="line.46"></a>
<FONT color="green">047</FONT>      private String trueString = "true";<a name="line.47"></a>
<FONT color="green">048</FONT>      /** String of false. */<a name="line.48"></a>
<FONT color="green">049</FONT>      private String falseString = "false";<a name="line.49"></a>
<FONT color="green">050</FONT>      /** String of signinForm. */<a name="line.50"></a>
<FONT color="green">051</FONT>      private String signinFormKey = "signinForm";<a name="line.51"></a>
<FONT color="green">052</FONT>      /** String of user. */<a name="line.52"></a>
<FONT color="green">053</FONT>      private String userKey = "user";<a name="line.53"></a>
<FONT color="green">054</FONT>      /** String of password. */<a name="line.54"></a>
<FONT color="green">055</FONT>      private String passwordKey = "password";<a name="line.55"></a>
<FONT color="green">056</FONT>      /** String of Signin. */<a name="line.56"></a>
<FONT color="green">057</FONT>      private String signinButtonKey = "Signin";<a name="line.57"></a>
<FONT color="green">058</FONT>      /**<a name="line.58"></a>
<FONT color="green">059</FONT>       * Initialize data for testing.<a name="line.59"></a>
<FONT color="green">060</FONT>       */<a name="line.60"></a>
<FONT color="green">061</FONT>      @Before<a name="line.61"></a>
<FONT color="green">062</FONT>      public void setUp() {<a name="line.62"></a>
<FONT color="green">063</FONT>        this.generateSimData(testUser, testProject, Tstamp.makeTimestamp(), 0);<a name="line.63"></a>
<FONT color="green">064</FONT>      }<a name="line.64"></a>
<FONT color="green">065</FONT>      <a name="line.65"></a>
<FONT color="green">066</FONT>      /**<a name="line.66"></a>
<FONT color="green">067</FONT>       * Test the daily project data page.<a name="line.67"></a>
<FONT color="green">068</FONT>       * From opening the page to showing the telemetry chart.<a name="line.68"></a>
<FONT color="green">069</FONT>       * Most information during navigation is checked.<a name="line.69"></a>
<FONT color="green">070</FONT>       */<a name="line.70"></a>
<FONT color="green">071</FONT>      @SuppressWarnings("unchecked")<a name="line.71"></a>
<FONT color="green">072</FONT>      @Test <a name="line.72"></a>
<FONT color="green">073</FONT>      public void testTelemetryPageNormalNavigation() {<a name="line.73"></a>
<FONT color="green">074</FONT>        this.generateSimData(testUser, testProject, Tstamp.makeTimestamp(), 3);<a name="line.74"></a>
<FONT color="green">075</FONT>    <a name="line.75"></a>
<FONT color="green">076</FONT>        Properties testProperties = getTestProperties();<a name="line.76"></a>
<FONT color="green">077</FONT>        testProperties.put(ProjectBrowserProperties.AVAILABLEPAGE_KEY + telemetry, trueString);<a name="line.77"></a>
<FONT color="green">078</FONT>        testProperties.put(ProjectBrowserProperties.BACKGROUND_PROCESS_KEY + telemetry, falseString);<a name="line.78"></a>
<FONT color="green">079</FONT>        WicketTester tester = new WicketTester(new ProjectBrowserApplication(testProperties));<a name="line.79"></a>
<FONT color="green">080</FONT>        tester.setupRequestAndResponse();<a name="line.80"></a>
<FONT color="green">081</FONT>        <a name="line.81"></a>
<FONT color="green">082</FONT>        tester.startPage(SigninPage.class); <a name="line.82"></a>
<FONT color="green">083</FONT>        // Let's sign in.<a name="line.83"></a>
<FONT color="green">084</FONT>        FormTester signinForm = tester.newFormTester(signinFormKey);<a name="line.84"></a>
<FONT color="green">085</FONT>        signinForm.setValue(userKey, testUserEmail);<a name="line.85"></a>
<FONT color="green">086</FONT>        signinForm.setValue(passwordKey, testUserEmail);<a name="line.86"></a>
<FONT color="green">087</FONT>        signinForm.submit(signinButtonKey);<a name="line.87"></a>
<FONT color="green">088</FONT>        //first, go to daily project data page.<a name="line.88"></a>
<FONT color="green">089</FONT>        tester.clickLink("TelemetryPageLink");<a name="line.89"></a>
<FONT color="green">090</FONT>        tester.assertRenderedPage(TelemetryPage.class);<a name="line.90"></a>
<FONT color="green">091</FONT>        <a name="line.91"></a>
<FONT color="green">092</FONT>        tester.assertComponent("inputPanel", TelemetryInputPanel.class);<a name="line.92"></a>
<FONT color="green">093</FONT>        <a name="line.93"></a>
<FONT color="green">094</FONT>        FormTester inputForm = tester.newFormTester("inputPanel:inputForm");<a name="line.94"></a>
<FONT color="green">095</FONT>        //checkt the date field.<a name="line.95"></a>
<FONT color="green">096</FONT>        inputForm.setValue("endDateTextField", getDateBeforeAsString(2));<a name="line.96"></a>
<FONT color="green">097</FONT>        inputForm.setValue("startDateTextField", getDateBeforeAsString(5));<a name="line.97"></a>
<FONT color="green">098</FONT>    <a name="line.98"></a>
<FONT color="green">099</FONT>        //check telemetry choices.<a name="line.99"></a>
<FONT color="green">100</FONT>        Component telemetryComponent = inputForm.getForm().get("telemetryMenu");<a name="line.100"></a>
<FONT color="green">101</FONT>        assertTrue("Check telemetry select field", telemetryComponent instanceof DropDownChoice);<a name="line.101"></a>
<FONT color="green">102</FONT>        DropDownChoice telemetryChoice = (DropDownChoice) telemetryComponent;<a name="line.102"></a>
<FONT color="green">103</FONT>        assertFalse("Telemetry should not be null", telemetryChoice.getChoices().isEmpty());<a name="line.103"></a>
<FONT color="green">104</FONT>        String telemetryName = telemetryChoice.getModelObjectAsString();<a name="line.104"></a>
<FONT color="green">105</FONT>        //inputForm.select("telemetryMenu", 1);<a name="line.105"></a>
<FONT color="green">106</FONT>    <a name="line.106"></a>
<FONT color="green">107</FONT>        //check the project list content.<a name="line.107"></a>
<FONT color="green">108</FONT>        Component projectComponent = inputForm.getForm().get("projectMenu");<a name="line.108"></a>
<FONT color="green">109</FONT>        assertTrue("Check project select field", projectComponent instanceof ListMultipleChoice);<a name="line.109"></a>
<FONT color="green">110</FONT>        ListMultipleChoice projectChoice = (ListMultipleChoice) projectComponent;<a name="line.110"></a>
<FONT color="green">111</FONT>        int defaultIndex = -1;<a name="line.111"></a>
<FONT color="green">112</FONT>        int testProjectIndex = -1;<a name="line.112"></a>
<FONT color="green">113</FONT>        for (int i = 0; i &lt; projectChoice.getChoices().size(); i++) {<a name="line.113"></a>
<FONT color="green">114</FONT>          Project project = (Project)projectChoice.getChoices().get(i);<a name="line.114"></a>
<FONT color="green">115</FONT>          if ("Default".equals(project.getName())) {<a name="line.115"></a>
<FONT color="green">116</FONT>            defaultIndex = i;<a name="line.116"></a>
<FONT color="green">117</FONT>          }<a name="line.117"></a>
<FONT color="green">118</FONT>          else if (testProject.equals(project.getName())) {<a name="line.118"></a>
<FONT color="green">119</FONT>            testProjectIndex = i;<a name="line.119"></a>
<FONT color="green">120</FONT>          }<a name="line.120"></a>
<FONT color="green">121</FONT>        }<a name="line.121"></a>
<FONT color="green">122</FONT>        if (defaultIndex &lt; 0) {<a name="line.122"></a>
<FONT color="green">123</FONT>          fail("Default project not found in project list.");<a name="line.123"></a>
<FONT color="green">124</FONT>        }<a name="line.124"></a>
<FONT color="green">125</FONT>        if (testProjectIndex &lt; 0) {<a name="line.125"></a>
<FONT color="green">126</FONT>          fail(testProject + " not found in project list.");<a name="line.126"></a>
<FONT color="green">127</FONT>        }<a name="line.127"></a>
<FONT color="green">128</FONT>        //select those choices.<a name="line.128"></a>
<FONT color="green">129</FONT>        inputForm.selectMultiple("projectMenu", new int[]{defaultIndex, testProjectIndex});<a name="line.129"></a>
<FONT color="green">130</FONT>        <a name="line.130"></a>
<FONT color="green">131</FONT>        inputForm.submit("submit");<a name="line.131"></a>
<FONT color="green">132</FONT>        //check the result.<a name="line.132"></a>
<FONT color="green">133</FONT>        tester.assertRenderedPage(TelemetryPage.class);<a name="line.133"></a>
<FONT color="green">134</FONT>        tester.assertComponent("dataPanel", TelemetryDataPanel.class);<a name="line.134"></a>
<FONT color="green">135</FONT>        tester.assertLabel("dataPanel:telemetryName", telemetryName);<a name="line.135"></a>
<FONT color="green">136</FONT>        //chart image should be empty initially.<a name="line.136"></a>
<FONT color="green">137</FONT>        tester.assertInvisible("dataPanel:selectedChart");<a name="line.137"></a>
<FONT color="green">138</FONT>        <a name="line.138"></a>
<FONT color="green">139</FONT>        FormTester streamForm = tester.newFormTester("dataPanel:streamForm");<a name="line.139"></a>
<FONT color="green">140</FONT>        <a name="line.140"></a>
<FONT color="green">141</FONT>        Component c1 = streamForm.getForm().get("dateList");<a name="line.141"></a>
<FONT color="green">142</FONT>        assertTrue("dateList should be ListView", c1 instanceof ListView);<a name="line.142"></a>
<FONT color="green">143</FONT>        ListView dateList = (ListView) c1;<a name="line.143"></a>
<FONT color="green">144</FONT>        assertEquals("There should be 4 dates in the table.", 4, dateList.getList().size());<a name="line.144"></a>
<FONT color="green">145</FONT>    <a name="line.145"></a>
<FONT color="green">146</FONT>        Component c2 = streamForm.getForm().get("projectTable");<a name="line.146"></a>
<FONT color="green">147</FONT>        assertTrue("dateList should be ListView", c2 instanceof ListView);<a name="line.147"></a>
<FONT color="green">148</FONT>        ListView projectTable = (ListView) c2;<a name="line.148"></a>
<FONT color="green">149</FONT>        assertEquals("There should be 2 projects in the table.", 2, projectTable.getList().size());<a name="line.149"></a>
<FONT color="green">150</FONT>        List projects = projectTable.getList();<a name="line.150"></a>
<FONT color="green">151</FONT>        List&lt;String&gt; projectNames = new ArrayList&lt;String&gt;();<a name="line.151"></a>
<FONT color="green">152</FONT>        projectNames.add(((Project)projects.get(0)).getName());<a name="line.152"></a>
<FONT color="green">153</FONT>        projectNames.add(((Project)projects.get(1)).getName());<a name="line.153"></a>
<FONT color="green">154</FONT>        assertTrue("Default project missed", projectNames.contains("Default"));<a name="line.154"></a>
<FONT color="green">155</FONT>        assertTrue("testProject project missed", projectNames.contains(testProject));<a name="line.155"></a>
<FONT color="green">156</FONT>    <a name="line.156"></a>
<FONT color="green">157</FONT>        //test selected chart display.<a name="line.157"></a>
<FONT color="green">158</FONT>        streamForm.setValue("projectTable:0:projectStream:0:streamCheckBox", String.valueOf(true));<a name="line.158"></a>
<FONT color="green">159</FONT>        streamForm.setValue("projectTable:1:projectStream:0:streamCheckBox", String.valueOf(true));<a name="line.159"></a>
<FONT color="green">160</FONT>        streamForm.submit();<a name="line.160"></a>
<FONT color="green">161</FONT>        tester.assertVisible("dataPanel:selectedChart");<a name="line.161"></a>
<FONT color="green">162</FONT>        /*<a name="line.162"></a>
<FONT color="green">163</FONT>        String selectedChartUrl = tester.getTagByWicketId("selectedChart").getAttribute("src");<a name="line.163"></a>
<FONT color="green">164</FONT>        assertTrue("chart image should be displayed now.", <a name="line.164"></a>
<FONT color="green">165</FONT>            selectedChartUrl.contains("http://chart.apis.google.com/chart?"));<a name="line.165"></a>
<FONT color="green">166</FONT>            */<a name="line.166"></a>
<FONT color="green">167</FONT>      }<a name="line.167"></a>
<FONT color="green">168</FONT>    <a name="line.168"></a>
<FONT color="green">169</FONT>      /**<a name="line.169"></a>
<FONT color="green">170</FONT>       * Test telemetry page with background process.<a name="line.170"></a>
<FONT color="green">171</FONT>       * The loading panel will show probably.<a name="line.171"></a>
<FONT color="green">172</FONT>       * The cancel button is working correctly.<a name="line.172"></a>
<FONT color="green">173</FONT>       */<a name="line.173"></a>
<FONT color="green">174</FONT>      @Test<a name="line.174"></a>
<FONT color="green">175</FONT>      public void testTelemetryPageBackgroundProcess() {<a name="line.175"></a>
<FONT color="green">176</FONT>        Properties testProperties = getTestProperties();<a name="line.176"></a>
<FONT color="green">177</FONT>        testProperties.put(ProjectBrowserProperties.AVAILABLEPAGE_KEY + telemetry, trueString);<a name="line.177"></a>
<FONT color="green">178</FONT>        testProperties.put(ProjectBrowserProperties.BACKGROUND_PROCESS_KEY + telemetry, trueString);<a name="line.178"></a>
<FONT color="green">179</FONT>        WicketTester tester = new WicketTester(new ProjectBrowserApplication(testProperties));<a name="line.179"></a>
<FONT color="green">180</FONT>        tester.setupRequestAndResponse();<a name="line.180"></a>
<FONT color="green">181</FONT>        <a name="line.181"></a>
<FONT color="green">182</FONT>        tester.startPage(SigninPage.class); <a name="line.182"></a>
<FONT color="green">183</FONT>        // Let's sign in.<a name="line.183"></a>
<FONT color="green">184</FONT>        FormTester signinForm = tester.newFormTester(signinFormKey);<a name="line.184"></a>
<FONT color="green">185</FONT>        signinForm.setValue(userKey, testUserEmail);<a name="line.185"></a>
<FONT color="green">186</FONT>        signinForm.setValue(passwordKey, testUserEmail);<a name="line.186"></a>
<FONT color="green">187</FONT>        signinForm.submit(signinButtonKey);<a name="line.187"></a>
<FONT color="green">188</FONT>        //first, go to daily project data page.<a name="line.188"></a>
<FONT color="green">189</FONT>        tester.clickLink("TelemetryPageLink");<a name="line.189"></a>
<FONT color="green">190</FONT>        tester.assertRenderedPage(TelemetryPage.class);<a name="line.190"></a>
<FONT color="green">191</FONT>        tester.assertComponent("inputPanel", TelemetryInputPanel.class);<a name="line.191"></a>
<FONT color="green">192</FONT>        <a name="line.192"></a>
<FONT color="green">193</FONT>        FormTester inputForm = tester.newFormTester("inputPanel:inputForm");<a name="line.193"></a>
<FONT color="green">194</FONT>        //check telemetry choices.<a name="line.194"></a>
<FONT color="green">195</FONT>        Component telemetryComponent = inputForm.getForm().get("telemetryMenu");<a name="line.195"></a>
<FONT color="green">196</FONT>        assertTrue("Check telemetry select field", telemetryComponent instanceof DropDownChoice);<a name="line.196"></a>
<FONT color="green">197</FONT>        DropDownChoice telemetryChoice = (DropDownChoice) telemetryComponent;<a name="line.197"></a>
<FONT color="green">198</FONT>        assertFalse("Telemetry should not be null", telemetryChoice.getChoices().isEmpty());<a name="line.198"></a>
<FONT color="green">199</FONT>        String telemetryName = telemetryChoice.getModelObjectAsString();<a name="line.199"></a>
<FONT color="green">200</FONT>        inputForm.submit("submit");<a name="line.200"></a>
<FONT color="green">201</FONT>        <a name="line.201"></a>
<FONT color="green">202</FONT>        //check the result.<a name="line.202"></a>
<FONT color="green">203</FONT>        tester.assertRenderedPage(TelemetryPage.class);<a name="line.203"></a>
<FONT color="green">204</FONT>        //loadingProcessPanel should be visible.<a name="line.204"></a>
<FONT color="green">205</FONT>        tester.assertComponent("loadingProcessPanel", LoadingProcessPanel.class);<a name="line.205"></a>
<FONT color="green">206</FONT>        //dataPanel should be invisible.<a name="line.206"></a>
<FONT color="green">207</FONT>        tester.assertInvisible("dataPanel");<a name="line.207"></a>
<FONT color="green">208</FONT>        //Check message in loadingProcessPanel<a name="line.208"></a>
<FONT color="green">209</FONT>        String msg = tester.getComponentFromLastRenderedPage("loadingProcessPanel:processingMessage").<a name="line.209"></a>
<FONT color="green">210</FONT>        getModelObjectAsString();<a name="line.210"></a>
<FONT color="green">211</FONT>        assertTrue("message error in loading panel", <a name="line.211"></a>
<FONT color="green">212</FONT>            msg.contains("Retrieving telemetry") &amp;&amp; msg.contains(telemetryName));<a name="line.212"></a>
<FONT color="green">213</FONT>        //check the cancel button.<a name="line.213"></a>
<FONT color="green">214</FONT>        FormTester cancelForm = tester.newFormTester("inputPanel:cancelForm");<a name="line.214"></a>
<FONT color="green">215</FONT>        cancelForm.submit("cancel");<a name="line.215"></a>
<FONT color="green">216</FONT>        assertTrue("Check process cancelled message."<a name="line.216"></a>
<FONT color="green">217</FONT>            , tester.getComponentFromLastRenderedPage("loadingProcessPanel:processingMessage").<a name="line.217"></a>
<FONT color="green">218</FONT>            getModelObjectAsString().contains("Process Cancelled."));<a name="line.218"></a>
<FONT color="green">219</FONT>      }<a name="line.219"></a>
<FONT color="green">220</FONT>      <a name="line.220"></a>
<FONT color="green">221</FONT>      /**<a name="line.221"></a>
<FONT color="green">222</FONT>       * Test pop up windows in telemetry page.<a name="line.222"></a>
<FONT color="green">223</FONT>       * All choices in telemetry menu should be in the description pop up window.<a name="line.223"></a>
<FONT color="green">224</FONT>       */<a name="line.224"></a>
<FONT color="green">225</FONT>      @SuppressWarnings("unchecked")<a name="line.225"></a>
<FONT color="green">226</FONT>      @Test<a name="line.226"></a>
<FONT color="green">227</FONT>      public void testTelemetryPopUpPanel() {<a name="line.227"></a>
<FONT color="green">228</FONT>        Properties testProperties = getTestProperties();<a name="line.228"></a>
<FONT color="green">229</FONT>        testProperties.put(ProjectBrowserProperties.AVAILABLEPAGE_KEY + telemetry, trueString);<a name="line.229"></a>
<FONT color="green">230</FONT>        testProperties.put(ProjectBrowserProperties.BACKGROUND_PROCESS_KEY + telemetry, falseString);<a name="line.230"></a>
<FONT color="green">231</FONT>        WicketTester tester = new WicketTester(new ProjectBrowserApplication(testProperties));<a name="line.231"></a>
<FONT color="green">232</FONT>        tester.setupRequestAndResponse();<a name="line.232"></a>
<FONT color="green">233</FONT>        <a name="line.233"></a>
<FONT color="green">234</FONT>        tester.startPage(SigninPage.class); <a name="line.234"></a>
<FONT color="green">235</FONT>        // Let's sign in.<a name="line.235"></a>
<FONT color="green">236</FONT>        FormTester signinForm = tester.newFormTester(signinFormKey);<a name="line.236"></a>
<FONT color="green">237</FONT>        signinForm.setValue(userKey, testUserEmail);<a name="line.237"></a>
<FONT color="green">238</FONT>        signinForm.setValue(passwordKey, testUserEmail);<a name="line.238"></a>
<FONT color="green">239</FONT>        signinForm.submit(signinButtonKey);<a name="line.239"></a>
<FONT color="green">240</FONT>        //first, go to daily project data page.<a name="line.240"></a>
<FONT color="green">241</FONT>        tester.clickLink("TelemetryPageLink");<a name="line.241"></a>
<FONT color="green">242</FONT>        tester.assertRenderedPage(TelemetryPage.class);<a name="line.242"></a>
<FONT color="green">243</FONT>        tester.assertComponent("inputPanel", TelemetryInputPanel.class);<a name="line.243"></a>
<FONT color="green">244</FONT>        <a name="line.244"></a>
<FONT color="green">245</FONT>        FormTester inputForm = tester.newFormTester("inputPanel:inputForm");<a name="line.245"></a>
<FONT color="green">246</FONT>        //get telemetry choices.<a name="line.246"></a>
<FONT color="green">247</FONT>        Component telemetryComponent = inputForm.getForm().get("telemetryMenu");<a name="line.247"></a>
<FONT color="green">248</FONT>        assertTrue("Check telemetry select field", telemetryComponent instanceof DropDownChoice);<a name="line.248"></a>
<FONT color="green">249</FONT>        DropDownChoice telemetryChoice = (DropDownChoice) telemetryComponent;<a name="line.249"></a>
<FONT color="green">250</FONT>        assertFalse("Telemetry should not be null", telemetryChoice.getChoices().isEmpty());<a name="line.250"></a>
<FONT color="green">251</FONT>        List choices = telemetryChoice.getChoices();<a name="line.251"></a>
<FONT color="green">252</FONT>        //click out the pop up window<a name="line.252"></a>
<FONT color="green">253</FONT>        tester.clickLink("inputPanel:inputForm:chartDefPopup:showModalWindow");<a name="line.253"></a>
<FONT color="green">254</FONT>        tester.assertComponentOnAjaxResponse("inputPanel:inputForm:chartDefPopup:modalWindow");<a name="line.254"></a>
<FONT color="green">255</FONT>        ModalWindow modalWindow = (ModalWindow) <a name="line.255"></a>
<FONT color="green">256</FONT>          tester.getComponentFromLastRenderedPage("inputPanel:inputForm:chartDefPopup:modalWindow");<a name="line.256"></a>
<FONT color="green">257</FONT>        //get the description list<a name="line.257"></a>
<FONT color="green">258</FONT>        TelemetryDescriptionPanel p = (TelemetryDescriptionPanel)<a name="line.258"></a>
<FONT color="green">259</FONT>                                            modalWindow.get(modalWindow.getContentId());<a name="line.259"></a>
<FONT color="green">260</FONT>        ListView listView = (ListView)p.get("descriptions");<a name="line.260"></a>
<FONT color="green">261</FONT>        List&lt;String&gt; telemetryInDescriptions = new ArrayList&lt;String&gt;();<a name="line.261"></a>
<FONT color="green">262</FONT>        for (Object o : listView.getList()) {<a name="line.262"></a>
<FONT color="green">263</FONT>          telemetryInDescriptions.add(((TelemetryChartDefinition)o).getName());<a name="line.263"></a>
<FONT color="green">264</FONT>        }<a name="line.264"></a>
<FONT color="green">265</FONT>        <a name="line.265"></a>
<FONT color="green">266</FONT>        assertTrue("All choices in telemetry menu should be in the description list.", <a name="line.266"></a>
<FONT color="green">267</FONT>            telemetryInDescriptions.containsAll(choices));<a name="line.267"></a>
<FONT color="green">268</FONT>        //assertTrue(choices.containsAll(telemetryInDescriptions));<a name="line.268"></a>
<FONT color="green">269</FONT>      }<a name="line.269"></a>
<FONT color="green">270</FONT>    <a name="line.270"></a>
<FONT color="green">271</FONT>      /**<a name="line.271"></a>
<FONT color="green">272</FONT>       * Test telemetry page with page parameters.<a name="line.272"></a>
<FONT color="green">273</FONT>       */<a name="line.273"></a>
<FONT color="green">274</FONT>      /*<a name="line.274"></a>
<FONT color="green">275</FONT>      @Test<a name="line.275"></a>
<FONT color="green">276</FONT>      public void testTelemetryWithPageParamters() {  //NOPMD WicketTester has its own assert classes.<a name="line.276"></a>
<FONT color="green">277</FONT>        Properties testProperties = getTestProperties();<a name="line.277"></a>
<FONT color="green">278</FONT>        testProperties.put(ProjectBrowserProperties.AVAILABLEPAGE_KEY + telemetry, trueString);<a name="line.278"></a>
<FONT color="green">279</FONT>        testProperties.put(ProjectBrowserProperties.BACKGROUND_PROCESS_KEY + telemetry, falseString);<a name="line.279"></a>
<FONT color="green">280</FONT>        WicketTester tester = new WicketTester(new ProjectBrowserApplication(testProperties));<a name="line.280"></a>
<FONT color="green">281</FONT>        tester.setupRequestAndResponse();<a name="line.281"></a>
<FONT color="green">282</FONT>        <a name="line.282"></a>
<FONT color="green">283</FONT>        <a name="line.283"></a>
<FONT color="green">284</FONT>        //but still need to sign in first.<a name="line.284"></a>
<FONT color="green">285</FONT>        tester.startPage(SigninPage.class);<a name="line.285"></a>
<FONT color="green">286</FONT>        <a name="line.286"></a>
<FONT color="green">287</FONT>        FormTester signinForm = tester.newFormTester(signinFormKey);<a name="line.287"></a>
<FONT color="green">288</FONT>        signinForm.setValue(userKey, testUserEmail);<a name="line.288"></a>
<FONT color="green">289</FONT>        signinForm.setValue(passwordKey, testUserEmail);<a name="line.289"></a>
<FONT color="green">290</FONT>        signinForm.submit(signinButtonKey);<a name="line.290"></a>
<FONT color="green">291</FONT>        <a name="line.291"></a>
<FONT color="green">292</FONT>        //TODO add test.<a name="line.292"></a>
<FONT color="green">293</FONT>        PageParameters param = new PageParameters("Build/Day/2008-05-24/2008-06-02/" + <a name="line.293"></a>
<FONT color="green">294</FONT>            this.testProject + "-" + this.testUser + "/*,*,*,*,false");<a name="line.294"></a>
<FONT color="green">295</FONT>        tester.startPage(TelemetryPage.class, param); <a name="line.295"></a>
<FONT color="green">296</FONT>        tester.assertRenderedPage(TelemetryPage.class);<a name="line.296"></a>
<FONT color="green">297</FONT>        <a name="line.297"></a>
<FONT color="green">298</FONT>      }<a name="line.298"></a>
<FONT color="green">299</FONT>      */<a name="line.299"></a>
<FONT color="green">300</FONT>      <a name="line.300"></a>
<FONT color="green">301</FONT>      /**<a name="line.301"></a>
<FONT color="green">302</FONT>       * Clear testing data.<a name="line.302"></a>
<FONT color="green">303</FONT>       */<a name="line.303"></a>
<FONT color="green">304</FONT>      @After<a name="line.304"></a>
<FONT color="green">305</FONT>      public void clear() {<a name="line.305"></a>
<FONT color="green">306</FONT>        this.clearData(testUserEmail);<a name="line.306"></a>
<FONT color="green">307</FONT>      }<a name="line.307"></a>
<FONT color="green">308</FONT>      <a name="line.308"></a>
<FONT color="green">309</FONT>      /**<a name="line.309"></a>
<FONT color="green">310</FONT>       * return a String that represent a date before today.<a name="line.310"></a>
<FONT color="green">311</FONT>       * @param i the number of days before today.<a name="line.311"></a>
<FONT color="green">312</FONT>       * @return a String represent today.<a name="line.312"></a>
<FONT color="green">313</FONT>       */<a name="line.313"></a>
<FONT color="green">314</FONT>      public String getDateBeforeAsString(int i) {<a name="line.314"></a>
<FONT color="green">315</FONT>        XMLGregorianCalendar time = Tstamp.incrementDays(Tstamp.makeTimestamp(), -i);<a name="line.315"></a>
<FONT color="green">316</FONT>        String timeString = time.getYear() + "-";<a name="line.316"></a>
<FONT color="green">317</FONT>        timeString += (time.getMonth() &gt;= 10) ? time.getMonth() : "0" + time.getMonth();<a name="line.317"></a>
<FONT color="green">318</FONT>        timeString += "-";<a name="line.318"></a>
<FONT color="green">319</FONT>        timeString += (time.getDay() &gt;= 10) ? time.getDay() : "0" + time.getDay();<a name="line.319"></a>
<FONT color="green">320</FONT>        return timeString;<a name="line.320"></a>
<FONT color="green">321</FONT>      }<a name="line.321"></a>
<FONT color="green">322</FONT>    }<a name="line.322"></a>




























































</PRE>
</BODY>
</HTML>
